<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script src="./d3.js"></script>
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/d3/7.0.0/d3.js"></script> -->
<script>
    // let oDiv = d3.select("body").append("div");
    // oDiv.style("width", "300px")
    // oDiv.style("height","200px")
    // oDiv.style("backGround", "red")
    // oDiv.style("width", 100)

    // let gen = d3.timeFormat('%Y-%m-%d-%H-%M-%S')
    // console.log(gen(Date.now()));

    const data = [
        {
            name: '1月',
            value: "800"
        },
        {
            name: '2月',
            value: "1000"
        },
        {
            name: '3月',
            value: "600"
        },
        {
            name: '4月',
            value: "1400"
        },
        {
            name: '5月',
            value: "1000"
        },
        {
            name: '6月',
            value: "500"
        }
    ]

    let lineGen = d3.line().x(item => (parseInt(item.name) - 1) * (600 / (data.length - 1))).y(item => 600 - item.value / 10)
    const res = lineGen(data)
    console.log(res);

    d3.select("body")
        .append('svg')
        .attr("width", 800)
        .attr("height", 600)
        .append("path")
        .attr("d", res)
        .attr("stroke", 'red')
        .attr("fill", "none")
</script>

</html>
